--- modules/path/path.admin.inc	13 Jan 2009 19:27:21 -0000	1.17
+++ modules/path/path.admin.inc	8 Apr 2009 08:24:06 -0000
@@ -144,7 +144,8 @@
   // Language is only set if locale module is enabled, otherwise save for all languages.
   $language = isset($form_state['values']['language']) ? $form_state['values']['language'] : '';
 
-  if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE pid != %d AND dst = '%s' AND language = '%s'", $pid, $dst, $language))) {
+  // Used alias for the same dst can be overwritten, otherwise should be an error.
+  if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE pid != %d AND src <> '%s' AND dst = '%s' AND language = '%s'", $pid, $src, $dst, $language))) {
     form_set_error('dst', t('The alias %alias is already in use in this language.', array('%alias' => $dst)));
   }
   $item = menu_get_item($src);
--- modules/path/path.module	30 Mar 2009 05:30:39 -0000	1.154
+++ modules/path/path.module	8 Apr 2009 08:21:28 -0000
@@ -97,10 +97,11 @@
     // Check for existing aliases.
     if ($alias == drupal_get_path_alias($path, $language)) {
       // There is already such an alias, neutral or in this language.
-      // Update the alias based on alias; setting the language if not yet done.
-      db_query("UPDATE {url_alias} SET src = '%s', dst = '%s', language = '%s' WHERE dst = '%s'", $path, $alias, $language, $alias);
+      db_query("UPDATE {url_alias} SET src = '%s' WHERE dst = '%s' AND language = '%s'", $path, $alias, $language);
     }
     else {
+      // Ensure that no similar aliases exist.
+      db_query("DELETE FROM {url_alias} WHERE dst = '%s' AND language = '%s'", $alias, $language);
       // A new alias. Add it to the database.
       db_query("INSERT INTO {url_alias} (src, dst, language) VALUES ('%s', '%s', '%s')", $path, $alias, $language);
     }
--- modules/path/path.test	31 Mar 2009 02:02:22 -0000	1.8
+++ modules/path/path.test	8 Apr 2009 08:21:16 -0000
@@ -53,6 +53,14 @@
     $this->assertNoText($node1->title, 'Previous alias no longer works.');
     $this->assertResponse(404);
 
+    // Try to set same alias again.
+    $edit['src'] = 'node/' . $node1->nid;
+    // leave $edit['dst'] the same
+    $this->drupalPost('admin/build/path/add', $edit, t('Create new alias'));
+
+    // Confirm no errors.
+    $this->assertNoText(t('The alias %alias is already in use in this language.', array('%alias' => $edit['dst'])), 'Alias for the same src can be overriden.');
+
     // Create second test node.
     $node2 = $this->drupalCreateNode();
 
@@ -70,6 +78,22 @@
     // Confirm that the alias no longer works.
     $this->drupalGet($edit['dst']);
     $this->assertNoText($node1->title, 'Alias was successfully deleted.');
+    
+    // Create third test node.
+    $node3 = $this->drupalCreateNode();
+
+    // Create set of aliases for one test node.
+    $path1 = $this->randomName(8);
+    $path2 = $this->randomName(8);
+    path_set_alias('node/' . $node3->nid, $path1);
+    path_set_alias('node/' . $node3->nid, $path2);
+
+    // Try to set second alias to third test node again.
+    $edit['src'] = 'node/' . $node3->nid;
+    $edit['dst'] = $path2;
+    $this->drupalPost('admin/build/path/add', $edit, t('Create new alias'));
+    // Should not get any duplicate errors.
+    $this->assertRaw(t('The alias has been saved.'), 'Alias was updated.');
   }
 
   /**

